<template>
  <div class="details">
    <Editor
      :value="value"
      :mode="mode"
      :plugins="plugins"
      @change="handleChange"
      :locale="zhHans"
    />
  </div>
</template>

<script setup lang="ts">
import gfm from "@bytemd/plugin-gfm";
import highlight from "@bytemd/plugin-highlight";
import { Editor, Viewer } from "@bytemd/vue-next";
import { ref, withDefaults, defineProps } from "vue";
import zhHans from "bytemd/lib/locales/zh_Hans.json";

const plugins = [
  // 在这里添加文本编辑器的组件
  gfm(),
  highlight(),
];

/**
 * 定义组件属性类型
 */
interface Props {
  value: string;
  mode?: string;
  handleChange: (v: string) => void;
}

/**
 * 给组件定义初始值
 */
const props = withDefaults(defineProps<Props>(), {
  value: () => "",
  mode: () => "split",
  handleChange: (v: string) => {
    // console.log(v);
  },
});
</script>

<style>
.bytemd-toolbar-icon.bytemd-tippy.bytemd-tippy-right:last-child {
  display: none;
}

.details {
  width: 1100px;
}
</style>
